package com.ruoyi.dingtalk.domain;

import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.dingtalk.domain.embeddable.DdDeptUserId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Objects;

/**
 * 钉钉用户部门和钉钉用户双绑定
 *
 * @author xueyu
 */
@ApiModel(value = "钉钉用户部门和钉钉用户双绑定")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@AllArgsConstructor
@TableName(value = "dd_user_dept")
@Entity
@Table(name = "dd_user_dept")
public class DdUserDept {

    @ApiModelProperty(value = "钉钉用户部门和钉钉用户双绑定联合主键")
    @EmbeddedId
    private DdDeptUserId ddDeptUserId;

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        DdUserDept that = (DdUserDept) o;
        return getDdDeptUserId() != null && Objects.equals(getDdDeptUserId(), that.getDdDeptUserId());
    }

    @Override
    public final int hashCode() {
        return Objects.hash(ddDeptUserId);
    }
}
